package atlantik.game.action;

import atlantik.game.Atlantik;
import atlantik.game.Game;

public class JoinGameAction extends AtlantikClientAction {

	private Game game;
	
	public JoinGameAction(Atlantik client) {
		super(client, "Join Game");
	}

	public void setSelectedGame(Game game) {
		this.game = game;
		update();
	}
	
	@Override
	public boolean canPerform() {
		if( !super.canPerform() || game == null || !game.canBeJoined())
			return false;
		return true; // defunct: game.getPlayers() < game.getMaxPlayers();
	}
	
	@Override
	public void perform() {
		if( game != null )
			client.join(game);
	}

}
